<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="fragments/easyui_insdep_head :: easyui_insdep_head" th:with="title='出货渠道管理'">
</head>
<body>

<table id="tt" class="easyui-datagrid" style="width:100%;height:100%" pageList='[1,10,20,30,50]'
       url="/exportChannel/getAllExportChannel"  singleSelect="true" pagination="true"
>
    <thead>
    <tr>
        <th field="exportchannelname" style="width:20%;">出货渠道名称</th>
        <th field="exportchannelnote" style="width:75%;">备注</th>
    </tr>
    </thead>
    <script type="text/javascript">
        //<![CDATA[
        $(function () {
            var pager = $('#tt').datagrid().datagrid('getPager');	// get the pager of datagrid
            pager.pagination({
                buttons: [{
                    iconCls: 'icon-add',
                    handler: function () {
                        windowOpen("添加出货渠道", "/exportChannel/exportChannelAddPage");
                    }
                }, {
                    iconCls: 'icon-edit',
                    handler: function () {
                        row = $("#tt").datagrid('getSelected');

                        if (row == null) {
                            $.messager.alert('警告', '请选中需要修改的出货渠道', 'info');
                            return;
                        }

                        windowOpen("修改出货渠道", "/exportChannel/exportChannelUpdatePage", row);
                    }
                }, {
                    iconCls: 'icon-remove',
                    handler: function () {
                        row = $("#tt").datagrid('getSelected');

                        if (row == null) {
                            $.messager.alert('警告', '请选中需要删除的出货渠道', 'info');
                            return;
                        }

                        $.messager.confirm('警告', '确定删除该出货渠道吗', function (r) {
                            if (r) {
                                $.post("/exportChannel/deleteExportChannel", {
                                    exportchannelid: row.exportchannelid
                                }, function (data) {
                                    var data = data == "success" ? "删除成功" : "删除失败";
                                    $.messager.alert('结果', data, 'info');
                                    $("#tt").datagrid("reload");
                                });
                            }
                        });
                    }
                }]
            });
        });
        //]]>
    </script>
</table>

<div id="ajaxWin" class="easyui-window" title=""
     data-options="modal:true,collapsible:true,closed:true,maximizable:false,minimizable:false,resizable:false"
     style="width:600px;height:500px;overflow: hidden">
    <iframe id="frame" name="frame" frameborder="0" style="height:100%;width:100%; "/>
</div>

<!--用于iframe post值的隐藏表单-->
<form target="frame" id="iframepostfrom" method="post">
    <input type="hidden" name="exportchannelid" id="ffexportchannelid"/>
    <input type="hidden" name="exportchannelname" id="ffexportchannelname"/>
    <input type="hidden" name="exportchannelnote" id="ffexportchannelnote"/>
</form>
<script type="text/javascript">
    //<![CDATA[
    $(function () {
        $('#ajaxWin').window({
            onBeforeClose: function () { //当面板关闭之前触发的事件
                $("#tt").datagrid("reload");
            }
        });
    });
    //]]>
</script>

<script type="text/javascript">
    //<![CDATA[
    function windowOpen(title, ajax_url, row) {
        $('#ajaxWin').panel({title: title});

        $("#iframepostfrom").attr("action", ajax_url);
        if (row != null) {
            $('#ffexportchannelid').val(row.exportchannelid);
            $('#ffexportchannelname').val(row.exportchannelname);
            $('#ffexportchannelnote').val(row.exportchannelnote);
        }

        $('#ajaxWin').window('open');
        $("#iframepostfrom").submit();
    }
    //]]>
</script>

</body>
</html>